{% extends 'base/tablehead.html' %}
{% block body %}

{#<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>#}
<script type="text/javascript">

    $("#checkAll").change(function () {
        $("input:checkbox").prop('checked', $(this).prop("checked"));
    });
    $(document).ready(function() {
        $("button").click(function(){
            var scan_id = ['a7af5b68-b661-45ad-90fd-ffa27526cdce'];
            $.each($("input[name='del_vuln_id']:checked"), function(){
                scan_id.push($(this).val());
            });

            var json_scanid = scan_id.join(", ");
            $.ajax({
                type:'POST',
                <!--contentType: 'application/json; charset=utf-8',-->
                url:'{% url 'inspec:inspec_del_vul' %}',
                data:{
                   del_vuln: json_scanid,
                   scan_id: $('input[name=scan_id]').val(),
                   csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val()
                },
                sucess:function(){
                }
            });
            setTimeout(function(){location.reload();},1000);
        });

    });


</script>

<div id="content">
    <div id="content-header">
        <div id="breadcrumb"><a href="/" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a> <a
                href="#" class="current">Vulnerabilities Details</a></div>
        <h1>Vulnerabilities List</h1>
    </div>

        <hr>
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"><i class="icon-th"></i></span>
                        <h5>Vulnerability List</h5>
                        <div class="buttons">
                            <button type="button" class="btn btn-danger btn-mini" onclick="">Delete Selected</button>
                        </div>
                    </div>

                    <div class="widget-content nopadding">
                        <table class="table table-bordered data-table table-fixed" width="100%">
                            <thead>
                            <tr>
                                <th><p><label><input type="checkbox" id="checkAll"/></label></p></th>
                                <th>Namespace Name</th>
                                <th>Feature Name</th>
                                <th>Feature Version</th>
                                <th>Severity</th>
                                <th>Link</th>
                                <th>False Positive</th>
                                <th>Status</th>
                                <th></th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>{% for data in inspec_vuln_data %}
                            <tr data-target="#">
                                <td>
                                    <form>
                                        <label><input type="checkbox" value="{{data.vuln_id}}" name="del_vuln_id">
                                        </label>
                                    </form>
                                </td>
                                <td><a href="{% url 'inspec:inspec_details' %}?scan_id={{data.scan_id}}&vuln_id={{data.vuln_id}}">{{data.Name}}</a>
                                </td>
                                <td>{{data.FeatureName}}</td>
                                <td>{{data.FeatureVersion}}</span></td>
                                <td><span class="badge badge-pill badge-{{data.vul_col}}">{{data.Severity}}</span></a>
                                </td>
                                <td><a href="#" target="_blank">{{data.Link}}</a>
                                </td>
                                <td>
                                    <form method="POST" action="{% url 'inspec:inspec_vuln_data' %}">{% csrf_token %}
                                        <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                        <input type="hidden" name="false" value="Yes">
                                        <input type="hidden" name="status" value="Open">
                                        <input type="hidden" name="vuln_name" value="{{data.Name}}">
                                        <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                        <button class="btn btn-info btn-mini">Yes</button>
                                    </form>
                                </td>
                                <td>{{data.vuln_status}}</td>
                                <td>
                                    <div>
                                        <form action="{% url 'inspec:inspec_del_vul' %}" method="POST"
                                              class="form-horizontal">
                                            {% csrf_token %}
                                            <input type="hidden" name="del_vuln" value="{{data.vuln_id}}">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-danger"><i class="icon-remove"></i></button>
                                        </form>
                                    </div>
                                </td>
                                <td>
                                    <form method="POST" action="{% url 'inspec:inspec_vuln_data' %}">{% csrf_token %}
                                        <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                        <input type="hidden" name="false" value="No">
                                        <input type="hidden" name="status" value="Closed">
                                        <input type="hidden" name="vuln_name" value="{{data.Name}}">
                                        <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                        <button class="btn btn-info btn-mini">Close</button>
                                    </form>
                                </td>
                            </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!--False Positive Vulnerability List-->
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"><i class="icon-th"></i></span>
                        <h5>False Positive Vulnerability List</h5>
                        <div class="buttons">
                            <button type="button" class="btn btn-danger btn-mini" onclick="">Delete Selected</button>
                        </div>
                    </div>

                    <div class="widget-content nopadding">
                        <table class="table table-bordered data-table table-fixed" width="100%">
                            <thead>
                            <tr>
                                <th><p><label><input type="checkbox" id="checkAll"/></label></p></th>
                                <th>Namespace Name</th>
                                <th>Feature Name</th>
                                <th>Severity</th>
                                <th>False Positive</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>{% for data in false_data %}
                            <tr data-target="#">
                                <td>
                                    <form>
                                        <label><input type="checkbox" value="{{data.vuln_id}}" name="del_vuln_id">
                                        </label>
                                    </form>
                                </td>
                                <td><a href="{% url 'inspec:inspec_details' %}?scan_id={{data.scan_id}}&vuln_id={{data.vuln_id}}">{{data.Name}}</a>
                                </td>
                                <td>{{data.FeatureName}}</td>
                                <td><span class="badge badge-pill badge-{{data.vul_col}}">{{data.Severity}}</span></td>
                                 <td>
                                    <form method="POST" action="{% url 'inspec:inspec_vuln_dat' %}/">{% csrf_token %}
                                        <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                        <input type="hidden" name="false" value="No">
                                        <input type="hidden" name="status" value="Open">
                                        <input type="hidden" name="vuln_name" value="{{data.Name}}">
                                        <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                        <button class="btn btn-info btn-mini">No</button>
                                    </form>
                                </td>
                                <td>
                                    <div>
                                        <form action="{% url 'inspec:inspec_del_vuln' %}" method="POST"
                                              class="form-horizontal">
                                            {% csrf_token %}
                                            <input type="hidden" name="del_vuln" value="{{data.vuln_id}}">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-danger"><i class="icon-remove"></i></button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"><i class="icon-th"></i></span>
                        <h5>Closed Vulnerabilities List</h5>
                        <!--<div class="buttons"><a data-toggle="modal" href="/add_vuln/?scan_id={{ scan_vul }}"-->
                        <!--class="btn btn-primary btn-mini"><i-->
                        <!--class="icon-plus icon-white"></i> Add new Vulnerability</a>-->
                        <!--</div>-->
                        <div class="buttons">
                            <button type="button" class="btn btn-danger btn-mini" onclick="">Delete Selected</button>
                        </div>
                    </div>

                    <div class="widget-content nopadding">
                        <table class="table table-bordered data-table table-fixed" width="100%">
                            <thead>
                            <tr>
                                <th><p><label><input type="checkbox" id="checkAll"/></label></p></th>
                                <th>Namespace Name</th>
                                <th>Feature Name</th>
                                <th>Severity</th>
                                <th>False Positive</th>
                                <th>Status</th>
                                <th></th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>{% for data in vuln_data_closed %}
                            <tr data-target="#">
                                <td>
                                    <form>
                                        <label><input type="checkbox" value="{{data.vuln_id}}" name="del_vuln_id">
                                        </label>
                                        <!--<br>-->
                                        <!--<button type="button" >Get Values</button>-->
                                    </form>
                                </td>
                                <td><a href="{% url 'inspec:inspec_details' %}?scan_id={{data.scan_id}}&vuln_id={{data.vuln_id}}">{{data.Name}}</a>
                                </td>
                                <td>{{data.FeatureName}}</td>
                                <td><span class="badge badge-pill badge-{{data.vul_col}}">{{data.Severity}}</span></td>
                                <td>
                                    <form method="POST" action="{% url 'inspec:inspec_vuln_data' %}">{% csrf_token %}
                                        <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                        <input type="hidden" name="false" value="No">
                                        <input type="hidden" name="status" value="Open">
                                        <input type="hidden" name="vuln_name" value="{{data.name}}">
                                        <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                        <button class="btn btn-info btn-mini">No</button>
                                    </form>
                                </td>
                                <td>{{data.vuln_status}}</td>
                                <td>
                                    <div>
                                        <form action="{% url 'inspec:inspec_del_vuln' %}" method="POST"
                                              class="form-horizontal">
                                            {% csrf_token %}
                                            <input type="hidden" name="del_vuln" value="{{data.vuln_id}}">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-danger"><i class="icon-remove"></i></button>
                                        </form>
                                    </div>
                                </td>
                                <td>
                                    <form method="POST" action="{% url 'inspec:inspec_vuln_data' %}">{% csrf_token %}
                                        <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                        <input type="hidden" name="false" value="No">
                                        <input type="hidden" name="status" value="Open">
                                        <input type="hidden" name="vuln_name" value="{{data.Name}}">
                                        <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                        <button class="btn btn-info btn-mini">Open</button>
                                    </form>
                                </td>
                            </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}